/**
* 作者 ：sunmeng
*
* 日期 ：2017/11/23
*
* 描述 ：目录审核--详情页
*/
<template>
  <el-container class="is-vertical">
    <HeaderBar :menuState="menuState"></HeaderBar>
    <BreadCrumb :options="breadOptions" class="breadcreamb"></BreadCrumb>
    <el-main class="cataDetail">
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="demo-ruleForm cataFrom">
				<el-form-item label="信息资源分类 :" prop="name">
				    <p>{{ ruleForm.dirName + "-"+ ruleForm.dirTypeName }}</p>
				</el-form-item>
			  	<el-form-item label="提供方名称或代码 :" prop="name">
				    <p>{{ ruleForm.departmentName + "_"+ ruleForm.departmentCode }}</p>
				</el-form-item>
		    <el-form-item class="infor" label="信息资源名称 :" prop="name">
				    <p>{{ ruleForm.name }}</p>
		    </el-form-item>
		    <el-form-item class="infor inforNum" label="信息资源代码 :">
			   	<p>{{ ruleForm.code }}</p>
		    </el-form-item>
			  <el-form-item label="信息资源摘要 :" prop="desc">
			    <p class="cataDes">{{ ruleForm.abstracts }}</p>
			  </el-form-item>
			  <el-form-item class="infor" label="信息资源格式 :" prop="name">
			    <p>{{ ruleForm.firstFormatName + "-" + ruleForm.secondFormatName }}</p>
			  </el-form-item>
			  <el-form-item class="infor" label="关联分类 :">
			  	<p>{{ ruleForm.relataionNames }}</p>
			  </el-form-item>
			  <h5>信息资源大普查</h5>
			  <div class="resources">
				  <el-form-item class="infor" label="数据存储总量 :" prop="name">
				    <p>{{ ruleForm.storageTotal +"G" }}</p>
				  </el-form-item>
				  <el-form-item class="infor" label="已共享的数据存储量 :" prop="name">
				    <p>{{ ruleForm.storageShareNum +"G" }}</p>
				  </el-form-item>
			  </div>
			  <div class="resources">
				  <el-form-item class="infor" label="已开放的数据存储量 :" prop="name">
				    <p>{{ ruleForm.storageOpenNum +"G" }}</p>
				  </el-form-item>
				  <el-form-item class="infor" label="结构化信息记录总数 :" prop="name">
				    <p>{{ ruleForm.structureRecordTotal +"万条" }}</p>
				  </el-form-item>
			  </div>
			  <div class="resources">
				  <el-form-item class="infor" label="已共享结构化信息记录总数 :" prop="name">
				    <p>{{ ruleForm.structureRecordShareNum +"万条" }}</p>
				  </el-form-item>
				  <el-form-item class="infor" label="已开放结构化信息记录总数 :" prop="name">
				    <p>{{ ruleForm.structureRecordOpenNum +"万条" }}</p>
				  </el-form-item>
			  </div>
			  <h5>信息项</h5>
			  <MTable :options="tableOptions" ref="myTable" class="tablebar"></MTable>
			  <el-button type="primary" @click="adopt"  class="elButton moduleButton elRight">通过</el-button>
			    <el-button @click="reject" type="info" class="elButton">驳回</el-button>
			</el-form>
    </el-main>
    <Dialog :options="dialogOptions">
      <AdoptForm slot="dialogContent" :options="dialogOptions" ref="adoptForm"></AdoptForm>
    </Dialog>
  </el-container>
</template>
<script>
  import axios from '../../plugins/axios'
  import checkDirAPIs from '../../api/checkDirAPIs'
  import HeaderBar from '../../components/header/Header.vue'
  import BreadCrumb from '../../components/breadcrumb/BreadCrumb.vue'
  import ModuleBar from '../../components/modulebar/ModuleBar.vue'
  import MTable from '../../components/table/Table.vue'
  import Dialog from '../../components/dialog/Dialog.vue'
  import AdoptForm from './components/adoptForm/AdoptForm.vue'

  export default {
    name: 'catalogAuditing',
    props:["formOptions"],
    components: {
      HeaderBar,
      BreadCrumb,
      ModuleBar,
      MTable,
      Dialog,
      AdoptForm
    },
    data() {
      let vm = this;
      return {
        menuState: "/catalogAuditing/main",
        moduleBarTitle: "审核列表",
        breadOptions: {
          bread: [
            {
              label: "政务数据资源管理系统",
              path: "/"
            }, {
              label: "目录审核",
              path: "/catalogAuditing/main"
            }, {
              label: "详情页",
              path: "/catalogAuditing/cataDetails"
            }
          ]
        },
        tableOptions: {
          handleSelectionChange(rows) {
          }
        },
        dialogOptions: {
          visible: false,
          title: "提示",
          label:"通过意见 :"
        },
        ruleForm: {

        },
        rules: {
          name: [
            { required: true},
          ]
        }
      }
    },
    mounted() {
      let vm = this,
        pageNo = 1,
        pageSize = 15;
				vm.cataDetailForm(pageNo,pageSize);
    },
    methods: {
    	cataDetailForm (pageNo,pageSize){
    		let vm = this
    		checkDirAPIs.checkInfoResourceRead({
					pageNum:pageNo,
					pageSize:pageSize,
					token:localStorage.token,
					key:vm.$router.history.current.query.id
				}).then(({ data }) => {
					console.log(data);
					if(data.code = 10000){
						vm.ruleForm=data.data
	          vm.initTable(data.data.infoPropertyList, pageNo, pageSize, data.data.total)
					}
				});
    	},
    	adopt() {
    		let vm = this;
          vm.dialogOptions.visible = true;
          vm.dialogOptions.label = "通过意见 :";
          vm.dialogOptions.submit=function(){
						checkDirAPIs.adopt({
							token:localStorage.token,
							key:vm.$router.history.current.query.id,
							checkOpinion:vm.$refs.adoptForm.getRefs("refName").$refs.textarea.value
						}).then(({ data }) => {
							console.log(data);
							if(data.code = 10000){
								vm.dialogOptions.visible = false
              	vm.$router.push({path: '/catalogAuditing/main'});
							}
						});
	        };
		      vm.dialogOptions.cancel=function(){
						vm.dialogOptions.visible = false
						vm.$refs.adoptForm.getRefs("refName").$refs.textarea.value =""
		      };

    	},
    	reject() {
    		let vm = this;
        vm.dialogOptions.visible = true;
        vm.dialogOptions.label = "驳回意见 :";
        vm.dialogOptions.submit=function(){
	      	checkDirAPIs.reject({
						token:localStorage.token,
						key:vm.$router.history.current.query.id,
						checkOpinion:vm.$refs.adoptForm.getRefs("refName").$refs.textarea.value
					}).then(({ data }) => {
						console.log(data);
						if(data.code = 10000){
							vm.dialogOptions.visible = false
              vm.$router.push({path: '/catalogAuditing/main'});
						}
					});
	      };
	      vm.dialogOptions.cancel=function(){
					vm.dialogOptions.visible = false
					vm.$refs.adoptForm.getRefs("refName").$refs.textarea.value =""
	      };

    	},
      initTable(dataList, pageNo, pageSize, total) {
        let vm = this
        vm.tableOptions = {
          thead: [{
            prop: "propertyName", // 数据的key值
            label: "信息项名称"
          }, {
            prop: "infoPropertyDataTypeName", // 数据的key值
            label: "数据项类型"
          }, {
            prop: "propertyDataLength", // 数据的key值
            label: "数据长度"
          }, {
            prop: "shareType", // 数据的key值
            label: "共享类型",
            formatter (row, column, cellValue) {
              switch (cellValue) {
                case 1 :
                  return "不共享"
                  break
                case 2 :
                  return "有条件共享"
                  break
                case 3 :
                  return "无条件共享"
                  break
              }
            }
          }, {
            prop: "shareModeName", // 数据的key值
            label: "共享方式"
          }, {
            prop: "isOpen", // 数据的key值
            label: "开放类型",
            formatter (row, column, cellValue) {
              switch (cellValue) {
                case 1 :
                  return "不开放"
                  break
                case 2 :
                  return "有条件开放"
                  break
                case 3 :
                  return "无条件开放"
                  break
              }
            }
          }, {
            prop: "openContent", // 数据的key值
            label: "开放条件"
          }, {
            prop: "updateCycle", // 数据的key值
            label: "更新周期",
            formatter (row, column, cellValue) {
              switch (cellValue) {
                case 1 :
                  return "实时"
                  break
                case 2 :
                  return "每日"
                  break
                case 3 :
                  return "每周"
                  break
                case 4 :
                  return "每季"
                  break
                case 5 :
                  return "每半年"
                  break
                case 6 :
                  return "每年"
                  break
                case 7 :
                  return "其他"
                  break
              }
            }
          }, {
            prop: "releaseTime", // 数据的key值
            label: "发布日期",
            formatter (row, column, cellValue) {
            	return new Date(parseInt(cellValue)).toLocaleDateString()
            }
          }, {
            prop: "description", // 数据的key值
            label: "备注(归属哪个系统)"
          }],
          data: dataList,
          pageInfo: {
            currentPage: pageNo,
            pageSizes: [15, 30, 45, 60],
            pageSize: pageSize,
            layout: "prev, pager, next, total, sizes, jumper",
            total: total,
            handleSizeChange(val) {
              console.log(val);
              vm.tableOptions.pageInfo.pageSize = val;
							vm.cataDetailForm(vm.tableOptions.pageInfo.currentPage, vm.tableOptions.pageInfo.pageSize)
            },
            handleCurrentChange(val) {
							vm.tableOptions.pageInfo.pageSize = val;
							vm.cataDetailForm(vm.tableOptions.pageInfo.currentPage, vm.tableOptions.pageInfo.pageSize)
            }
          }
        }
      }
    }
  }
</script>
<style>
	.cataDetail{
		width: 70%;
		padding-top: 40px;
		margin: 0 auto;
	}
	.cataDetail .cataFrom p{
		text-align: left;
		font-size: 1.4rem;
		color: #666;
	}
	.cataDetail .cataFrom h5{
		font-size: 1.8rem;
		color: #076bc1;
		text-align: left;
		padding-left: 10px;
		border-left: 5px solid #076bc1;
		margin: 10px 0 20px 0;
	}
	.cataDetail .cataFrom label{
		text-align: left !important;
	}
	.cataDetail .cataFrom .cataDes{
		margin-left: 115px;
		line-height: 36px;
	}
	.cataDetail .cataFrom .elButton{
		width: 112px;
		height: 36px;
		margin: 40px 0;
		padding: 0;
	}
	.cataDetail .cataFrom .elRight{
		margin-right: 60px;
	}
	.cataDetail .cataFrom .resources label{
		/*margin-left: 10%;*/
	}
	.dialogTitleBar{
		padding-left: 10px;
	}
  .tablebarAudit {
    width: 94%;
    margin: 20px auto;
  }
  .tablebarAudit .toolbar .toolbarItem{
    width: auto;
  }
  .tablebarAudit .tableContainer table td button:last-child span {
    color: #e15959;
  }
  .resources{
		overflow: hidden;
	}
	.resources .infor{
		width: 50%;
		float: left;
	}
</style>
